package com.demo.chenboqun.a13_simpleplay;


import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.IBinder;
import android.widget.Toast;

public class MusicService extends Service{
    private MediaPlayer mediaPlayer;
    @Override
    public void onCreate() {
        mediaPlayer=MediaPlayer.create(getApplicationContext(),R.raw.gequ);
        mediaPlayer.setLooping(true);
        super.onCreate();
    }

    @Override
    public void onStart(Intent intent, int startId) {
        Toast.makeText(MusicService.this,"MusicService onStart()"
                        ,Toast.LENGTH_SHORT).show();
        mediaPlayer.start();
        super.onStart(intent, startId);
    }

    @Override
    public void onDestroy() {
        Toast.makeText(MusicService.this,"MusicService onDestroy()"
                    ,Toast.LENGTH_SHORT).show();
        mediaPlayer.stop();
        super.onDestroy();
    }

    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }
}
